import './App.css';
import Tabbar from './components/Tabbar';
import { Redirect, Route, Switch } from 'react-router-dom';
import React, { Component } from 'react';
import {index_banner} from './api/index'
import Login from './views/Login';
import Register from './views/Register';
import Home from './views/Home'
import Cate from './views/Cate'
import Good from './views/Good'
import Profile from './views/Profile'
import Shopcart from './views/Shopcart'
import NotFound from './views/NotFound';
class App extends Component {
  componentDidMount(){
    index_banner().then((res)=>{
      console.log(res);
    })
  }
  render() {
    return (
      <div>
        {/* 定义路由规则 */}
        {/* Route组件本身充当的就是router-view的功能(组件渲染出口) */}
        {/* exact 表示严格匹配,必须完全相等,才能匹配成功 */}
        {/* path='*' 表示匹配所有路由地址 */}
        {/* <Login /> */}
        {/* <Register /> */}
        <Switch>
          <Route exact path="/login" component={Login}></Route>
          <Route exact path="/register" component={Register}></Route>
          <Route exact path="/home" component={Home} ></Route>
          <Route exact path="/cate" component={Cate} ></Route>
          <Route exact path="/good" component={Good} ></Route>
          <Route exact path="/shopcart" component={Shopcart} ></Route>
          <Route exact path="/profile" component={Profile} ></Route>
          <Redirect exact from='/' to='/home'></Redirect>
          <Route path="*" component={NotFound} ></Route>
        </Switch>

        <Tabbar></Tabbar>
      </div>
    );
  }
}

export default App;
